﻿
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows.Forms
Imports System.IO




Public Class Form7

    Private dataAdapter As New SqlClient.SqlDataAdapter()


 

    Private Sub Form7_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'TODO: This line of code loads data into the 'CADISDataSet6.F0004' table. You can move, or remove it, as needed.
        Me.F0004TableAdapter.Fill(Me.CADISDataSet6.F0004)
   

        Me.Size = My.Settings.Form7Size
        FormPos(My.Settings.Form7Pos)
        Me.Location = My.Settings.Form7Pos

        If File.Exists(My.Settings.ConfigPath & "\Form7GW01.xml") Then GridView1.RestoreLayoutFromXml(My.Settings.ConfigPath & "\Form7GW01.xml")

    End Sub

 

    Private Sub Form7_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        My.Settings.Form7Size = Me.Size
        My.Settings.Form7Pos = Me.Location

        'Save all gridview setups
        If Not Directory.Exists(My.Settings.ConfigPath) Then Directory.CreateDirectory(My.Settings.ConfigPath)

        Try
            GridView1.SaveLayoutToXml(My.Settings.ConfigPath & "\Form7GW01.xml")
        Catch ex As Exception

        End Try


    End Sub


    Private Sub BarButtonItem1_ItemClick(sender As System.Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
        'Load data to excel
        Const filename As String = "c:\JLD004_Form7_Data.xls"

        If File.Exists(filename) Then
            File.Delete(filename)
        End If

        GridControl1.ExportToXls(filename)

        Dim app = New Microsoft.Office.Interop.Excel.Application
        app.Visible = True

        app.Workbooks.Open(System.IO.Path.GetFullPath(filename))
    End Sub
End Class